<?php


namespace platform\controllers\authority;


use platform\controllers\BaseController;
use platform\models\authority\Route;

class RouteController extends BaseController
{
    public $modelClass = 'platform\models\authority\Route';

    public function actions()
    {
        $actions = parent::actions();

        // 禁用 "delete" 和 "create" 动作
        unset($actions['index'], $actions['view'], $actions['create'], $actions['update'], $actions['delete']);

        return $actions;
    }

    public function actionAppRoutes()
    {
        (new Route())->initRoutes();

        $items = Array_values((new Route())->getAssignedRoutes());
        sort($items);
        return ['items' => $items];
    }

    public function actionUpdate()
    {
        $model = new Route();
        $model->load(\Yii::$app->request->post(), '');
        return $model->update();
    }
}